package util;

/**
 * @Description 异常相关工具类
 */
public class ExceptionUtils {
    private ExceptionUtils() {
        
    }
    
    /**
     * @Description 获取异常的堆栈信息
     */
    public static String getStackTrace(Throwable throwable) {
        StringBuilder sb = new StringBuilder();
        sb.append(throwable.toString()).append(System.getProperty("line.separator")).append("    ");
        sb.append(getStackTrace(throwable.getStackTrace()));
        return sb.toString();
    }
    
    /**
     * @Description 获取堆栈信息
     */
    public static String getStackTrace(StackTraceElement[] stackTraces) {
        StringBuilder sb = new StringBuilder();
        for (StackTraceElement ste : stackTraces) {
            sb.append(ste.toString()).append(System.getProperty("line.separator")).append("    ");
        }
        return sb.toString();
    }

    /**
     * @Description 处理异常
     */
    public static void handleException(Throwable e) {
        // 默认不处理
    }

}
